

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#tuya_cloud_types.h" class="nav-sub-label">tuya_cloud_types.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#_MEM_POOL_H" class="nav-sub-label">_MEM_POOL_H</a>
              </li>
      

              <li>
                <a href="#SYS_MEM_DEBUG" class="nav-sub-label">SYS_MEM_DEBUG</a>
              </li>
      

              <li>
                <a href="#SHOW_MEM_POOL_DEBUG" class="nav-sub-label">SHOW_MEM_POOL_DEBUG</a>
              </li>
      

              <li>
                <a href="#MEM_POOL_MUTLI_THREAD" class="nav-sub-label">MEM_POOL_MUTLI_THREAD</a>
              </li>
      

              <li>
                <a href="#Malloc(x)" class="nav-sub-label">Malloc(x)</a>
              </li>
      

              <li>
                <a href="#Calloc(x)" class="nav-sub-label">Calloc(x)</a>
              </li>
      

              <li>
                <a href="#Free(x)" class="nav-sub-label">Free(x)</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#SysMemoryPoolSetup" class="nav-sub-label">SysMemoryPoolSetup</a>
              </li>
      

              <li>
                <a href="#SysMemPoolSetupUserDef" class="nav-sub-label">SysMemPoolSetupUserDef</a>
              </li>
      

              <li>
                <a href="#SysMemoryPoolDelete" class="nav-sub-label">SysMemoryPoolDelete</a>
              </li>
      

              <li>
                <a href="#MemPartitionCreate" class="nav-sub-label">MemPartitionCreate</a>
              </li>
      

              <li>
                <a href="#MemPartitionDelete" class="nav-sub-label">MemPartitionDelete</a>
              </li>
      

              <li>
                <a href="#MemBlockGet" class="nav-sub-label">MemBlockGet</a>
              </li>
      

              <li>
                <a href="#MemBlockPut" class="nav-sub-label">MemBlockPut</a>
              </li>
      

              <li>
                <a href="#MallocFromSysMemPool" class="nav-sub-label">MallocFromSysMemPool</a>
              </li>
      

              <li>
                <a href="#FreeFromSysMemPool" class="nav-sub-label">FreeFromSysMemPool</a>
              </li>
      

              <li>
                <a href="#ShowSysMemPoolInfo" class="nav-sub-label">ShowSysMemPoolInfo</a>
              </li>
      

              <li>
                <a href="#__Malloc" class="nav-sub-label">__Malloc</a>
              </li>
      

              <li>
                <a href="#__Free" class="nav-sub-label">__Free</a>
              </li>
      

              <li>
                <a href="#Malloc" class="nav-sub-label">Malloc</a>
              </li>
      

              <li>
                <a href="#Calloc" class="nav-sub-label">Calloc</a>
              </li>
      

              <li>
                <a href="#Free" class="nav-sub-label">Free</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#MEM_PARTITION;
" class="nav-sub-label">MEM_PARTITION;
</a>
              </li>
      

              <li>
                <a href="#MEM_POOL_SETUP_TBL;
" class="nav-sub-label">MEM_POOL_SETUP_TBL;
</a>
              </li>
      
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="tuya_cloud_types.h"><span>tuya_cloud_types.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_cloud_types.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_cloud_types.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="_MEM_POOL_H">Marco <span>_MEM_POOL_H</span></h4>
      <pre class="doc-declare"><code>#define _MEM_POOL_H
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="SYS_MEM_DEBUG">Marco <span>SYS_MEM_DEBUG</span></h4>
      <pre class="doc-declare"><code>#define SYS_MEM_DEBUG 0 
</code></pre>
      <pre class="doc-comment">/**
 * @brief system memory debug flag
 * 
 */</pre>

      <h4 id="SHOW_MEM_POOL_DEBUG">Marco <span>SHOW_MEM_POOL_DEBUG</span></h4>
      <pre class="doc-declare"><code>#define SHOW_MEM_POOL_DEBUG 1 
</code></pre>
      <pre class="doc-comment">/**
 * @brief system memory debug  display flag
 * 
 */</pre>

      <h4 id="MEM_POOL_MUTLI_THREAD">Marco <span>MEM_POOL_MUTLI_THREAD</span></h4>
      <pre class="doc-declare"><code>#define MEM_POOL_MUTLI_THREAD 1
</code></pre>
      <pre class="doc-comment">/**
 * @brief support multi thread memory process
 * 
 */</pre>

      <h4 id="Malloc(x)">Marco <span>Malloc(x)</span></h4>
      <pre class="doc-declare"><code>#define Malloc(x) __Malloc(x,__FILE__,__LINE__)
</code></pre>
      <pre class="doc-comment">/**
 * @brief malloc memory
 * 
 * @param[in] reqSize the required memory size 
 * @return  NULL on failed, others on the address of the memory
 */</pre>

      <h4 id="Calloc(x)">Marco <span>Calloc(x)</span></h4>
      <pre class="doc-declare"><code>#define Calloc(x) __Calloc(x, y,__FILE__,__LINE__)
</code></pre>
      <pre class="doc-comment">/**
 * @brief malloc consecutive memory, the size is reqCount*reqSize
 * 
 * @param[in] reqCount the required memory count
 * @param[in] reqSize the required memory szie
 * @return NULL on failed, others on the address of the memory
 */</pre>

      <h4 id="Free(x)">Marco <span>Free(x)</span></h4>
      <pre class="doc-declare"><code>#define Free(x) __Free(x,__FILE__,__LINE__)
</code></pre>
      <pre class="doc-comment">/**
 * @brief free memory
 * 
 * @param[in] pReqMem the memory address which got from Malloc or Calloc function
 * @return VOID 
 */</pre>
      <h3 id="functions">Functions</h3>
      

      <h4 id="SysMemoryPoolSetup">Func <span>SysMemoryPoolSetup</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET SysMemoryPoolSetup(VOID);</code></pre>
      <pre class="doc-comment">/**
 * @brief setup the memory pool use default memory pool table and partition number
 * 
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h    
 */</pre>

      <h4 id="SysMemPoolSetupUserDef">Func <span>SysMemPoolSetupUserDef</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET SysMemPoolSetupUserDef(IN CONST MEM_POOL_SETUP_TBL *tbl, IN CONST INT_T cnt);</code></pre>
      <pre class="doc-comment">/**
 * @brief setup the memory pool use user defined memory pool table and partition number
 * 
 * @param[in] tbl the memory pool table
 * @param[in] cnt the partition number
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h     
 */</pre>

      <h4 id="SysMemoryPoolDelete">Func <span>SysMemoryPoolDelete</span></h4>
      <pre class="doc-declare"><code>VOID SysMemoryPoolDelete(VOID);</code></pre>
      <pre class="doc-comment">/**
 * @brief delete memory pool
 * 
 * @return VOID 
 */</pre>

      <h4 id="MemPartitionCreate">Func <span>MemPartitionCreate</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET MemPartitionCreate(IN CONST DWORD_T nblks, IN CONST DWORD_T blksize, OUT MEM_PARTITION **ppMemPartition);</code></pre>
      <pre class="doc-comment">/**
 * @brief create memory partotion
 * 
 * @param[in] nblks the number of memory block in partition
 * @param[in] blksize the size of memory block in partition
 * @param[out] ppMemPartition the memory partition
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h     
 */</pre>

      <h4 id="MemPartitionDelete">Func <span>MemPartitionDelete</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET MemPartitionDelete(IN MEM_PARTITION *pMemPart);</code></pre>
      <pre class="doc-comment">/**
 * @brief delete memory partition
 * 
 * @param[in] pMemPart the memory partition need to delete
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h  
 */</pre>

      <h4 id="MemBlockGet">Func <span>MemBlockGet</span></h4>
      <pre class="doc-declare"><code>VOID *MemBlockGet(INOUT MEM_PARTITION *pMemPart, OUT OPERATE_RET *pOprtRet);</code></pre>
      <pre class="doc-comment">/**
 * @brief get a memory block from a partition
 * 
 * @param[in] pMemPart the input memory partition
 * @param[out] pOprtRet the operation return value, OPRT_OK on success, others on failed, please refer to tuya_error_code.h
 * @return the memory block address 
 */</pre>

      <h4 id="MemBlockPut">Func <span>MemBlockPut</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET MemBlockPut(INOUT MEM_PARTITION *pMemPart, IN CONST VOID *pblk);</code></pre>
      <pre class="doc-comment">/**
 * @brief release memory block to partition
 * 
 * @param[in] pMemPart the memory partition
 * @param[in] pblk the memory block address need to release
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h 
 */</pre>

      <h4 id="MallocFromSysMemPool">Func <span>MallocFromSysMemPool</span></h4>
      <pre class="doc-declare"><code>VOID *MallocFromSysMemPool(IN CONST DWORD_T reqSize,OPERATE_RET *pRet);</code></pre>
      <pre class="doc-comment">/**
 * @brief malloc memory from memory pool
 * 
 * @param[in] reqSize the size of memory required
 * @param[in] pRet the operation return value, OPRT_OK on success, others on failed, please refer to tuya_error_code.h
 * @return the address of the memory
 */</pre>

      <h4 id="FreeFromSysMemPool">Func <span>FreeFromSysMemPool</span></h4>
      <pre class="doc-declare"><code>OPERATE_RET FreeFromSysMemPool(IN PVOID_T pReqMem);</code></pre>
      <pre class="doc-comment">/**
 * @brief free the memory to memory pool
 * 
 * @param[in] pReqMem the memory which got from MallocFromSysMemPool function
 * @return OPRT_OK on success, others on failed, please refer to tuya_error_code.h 
 */</pre>

      <h4 id="ShowSysMemPoolInfo">Func <span>ShowSysMemPoolInfo</span></h4>
      <pre class="doc-declare"><code>VOID ShowSysMemPoolInfo(VOID);</code></pre>
      <pre class="doc-comment">/**
 * @brief display the memory pool detail info, only valid when SHOW_MEM_POOL_DEBUG=1
 * 
 * @return VOID 
 */</pre>

      <h4 id="__Malloc">Func <span>__Malloc</span></h4>
      <pre class="doc-declare"><code>VOID *__Malloc(IN CONST DWORD_T reqSize,IN CONST CHAR_T *file,IN CONST INT_T line);</code></pre>
      <pre class="doc-comment">/**
 * @brief a debug function which can record the file and line infomation when call Malloc
 * 
 * @param[in] reqSize the required memory size
 * @param[in] file the file name where Malloc called
 * @param[in] line the line where Malloc called
 * @return the memory address got from system memory pool
 */</pre>

      <h4 id="__Free">Func <span>__Free</span></h4>
      <pre class="doc-declare"><code>VOID __Free(IN PVOID_T pReqMem,IN CONST CHAR_T *file,IN CONST INT_T line);</code></pre>
      <pre class="doc-comment">/**
 * @brief a debug function which can record the file and line infomation when call Free
 * 
 * @param[in] pReqMem the memory address which need to free
 * @param[in] file the file name where Free called
 * @param[in] line the line where Free called
 * @return VOID 
 */</pre>

      <h4 id="Malloc">Func <span>Malloc</span></h4>
      <pre class="doc-declare"><code>VOID *Malloc(IN SIZE_T reqSize);</code></pre>
      <pre class="doc-comment">/**
 * @brief malloc memory
 * 
 * @param[in] reqSize the required memory size 
 * @return  NULL on failed, others on the address of the memory
 */</pre>

      <h4 id="Calloc">Func <span>Calloc</span></h4>
      <pre class="doc-declare"><code>VOID *Calloc(IN CONST DWORD_T reqCount, IN SIZE_T reqSize);</code></pre>
      <pre class="doc-comment">/**
 * @brief malloc consecutive memory, the size is reqCount*reqSize
 * 
 * @param[in] reqCount the required memory count
 * @param[in] reqSize the required memory szie
 * @return NULL on failed, others on the address of the memory
 */</pre>

      <h4 id="Free">Func <span>Free</span></h4>
      <pre class="doc-declare"><code>VOID Free(IN PVOID_T pReqMem);</code></pre>
      <pre class="doc-comment">/**
 * @brief free memory
 * 
 * @param[in] pReqMem the memory address which got from Malloc or Calloc function
 * @return VOID 
 */</pre>
      <h3 id="vars">Vars</h3>
      
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      

      <h4 id="MEM_PARTITION;
">Typedef <span>MEM_PARTITION;
</span></h4>
      <pre class="doc-declare"><code>typedef struct {               // MEMORY CONTROL BLOCK                                         
   VOID  *pMemAddr;          // Pointer to beginning of memory partition    
   VOID  *pMemAddrEnd;       // Pointer to ending of memory partition
   VOID  *pMemFreeList;      // Pointer to list of free memory blocks                        
   DWORD_T memBlkSize;       // Size (in bytes) of each block of memory                      
   DWORD_T memNBlks;         // Total number of blocks in this partition                     
   DWORD_T memNFree;         // Number of memory blocks remaining in this partition          
}MEM_PARTITION;
</code></pre>
      <pre class="doc-comment">/**
 * @brief the memory partition
 * 
 */</pre>

      <h4 id="MEM_POOL_SETUP_TBL;
">Typedef <span>MEM_POOL_SETUP_TBL;
</span></h4>
      <pre class="doc-declare"><code>typedef struct {
   DWORD_T memBlkSize; // 块大小 >=2
   DWORD_T memNBlks; // 块数量
}MEM_POOL_SETUP_TBL;
</code></pre>
      <pre class="doc-comment">/**
 * @brief the memory pool table
 * 
 */</pre>
    </div>
  </body>
</html>
            